nlp_architect.data.cdc_resources.relations.computed_relation_extraction.ComputedRelationExtraction

class nlp_architect.data.cdc_resources.relations.computed_relation_extraction.ComputedRelationExtraction[source]

Extract Relation between two mentions according to computation and rule based algorithms

__init__()

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__() Initialize self.
extract_all_relations(mention_x, mention_y) Try to find if mentions has anyone or more of the relations this class support
extract_exact_string(mention_x, mention_y) Check if input mentions has exact string relation
extract_fuzzy_fit(mention_x, mention_y) Check if input mentions has fuzzy fit relation
extract_fuzzy_head_fit(mention_x, mention_y) Check if input mentions has fuzzy head fit relation
extract_relation(mention_x, mention_y, relation) Base Class Check if Sub class support given relation before executing the sub class
extract_same_head_lemma(mention_x, mention_y) Check if input mentions has same head lemma relation
extract_sub_relations(mention_x, mention_y, …) Check if input mentions has the given relation between them
get_supported_relations() Return all supported relations by this class
extract_all_relations(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight) → Set[nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType][source]

Try to find if mentions has anyone or more of the relations this class support

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
Returns:

One or more of: RelationType.EXACT_STRING, RelationType.FUZZY_FIT,

RelationType.FUZZY_HEAD_FIT, RelationType.SAME_HEAD_LEMMA, RelationType.SAME_HEAD_LEMMA_RELAX

Return type:

Set[RelationType]

static extract_exact_string(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has exact string relation

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
Returns:

RelationType.EXACT_STRING or RelationType.NO_RELATION_FOUND

static extract_fuzzy_fit(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has fuzzy fit relation

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
Returns:

RelationType.FUZZY_FIT or RelationType.NO_RELATION_FOUND

static extract_fuzzy_head_fit(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has fuzzy head fit relation

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
Returns:

RelationType.FUZZY_HEAD_FIT or RelationType.NO_RELATION_FOUND

extract_relation(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight, relation: nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType

Base Class Check if Sub class support given relation before executing the sub class

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
  • relation – RelationType
Returns:

relation in case mentions has given relation and

RelationType.NO_RELATION_FOUND otherwise

Return type:

RelationType

static extract_same_head_lemma(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has same head lemma relation

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
Returns:

RelationType.SAME_HEAD_LEMMA or RelationType.NO_RELATION_FOUND

extract_sub_relations(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight, relation: nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has the given relation between them

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
  • relation – RelationType
Returns:

relation in case mentions has given relation or

RelationType.NO_RELATION_FOUND otherwise

Return type:

RelationType

static get_supported_relations() → List[nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType][source]

Return all supported relations by this class

Returns:List[RelationType]